/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.actions.login;

import com.mapping.Empleado;
import com.mapping.Login;
import com.mapping.TipoLogin;
import com.opensymphony.xwork2.ActionSupport;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;

/**
 *
 * @author Ricardo
 */
@Namespace(value = "/")
@Action(value = "consultaLogin", results = {
@Result(name = "success", location = "/Login/resultadoConsultaLogin.jsp")})
public class ConsultasLoginAction extends ActionSupport{
    private int idLogin;
    private Login login;
    private Empleado empleado;
    private TipoLogin tipo;
    
    @Override
    public String execute(){                  
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("inventarios");
        EntityManager em = emf.createEntityManager();
        EntityTransaction tx = em.getTransaction();
        tx.begin();                     
        login = (Login)em.getReference(Login.class, idLogin);        
        empleado = login.getIdempleado();
        tipo = login.getIdTipo();       
        em.flush();
        tx.commit();
        em.close();           
        return SUCCESS;
    }

    public Login getLogin() {
        return login;
    }

    public void setIdLogin(int idLogin) {
        this.idLogin = idLogin;
    }

    public Empleado getEmpleado() {
        return empleado;
    }        

    public TipoLogin getTipo() {
        return tipo;
    }
        
}
